﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;
using System.Data;
using KPIS.Utils;
using KPIS.DBM;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.MODEL;
using Telerik.Web.UI;


namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class TR_TrainingCompareGroups : System.Web.UI.UserControl
    {
        private object _dataItem = null;
        InitialData_BLL iniData = new InitialData_BLL();

        //ReadOnly property.
        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }
        protected bool IsUserControlPostBack
        {
            get
            {
                return this.ViewState["IsUserControlPostBack"] != null;
            }
        }
        //Initializing the new variable updating ViewState data.
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!IsUserControlPostBack)
            {
              
                this.ViewState.Add("IsUserControlPostBack", true);
            }

            if (DataItem != null)
            {
                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {
                    lblID.Text = DataBinder.Eval(DataItem, "compare_group_seq").ToString();
                    txtID.Text = DataBinder.Eval(DataItem, "compare_group_code").ToString();
                    txtName.Text = DataBinder.Eval(DataItem, "compare_group_descr").ToString();
                   
                    this.btnAddnew.Visible = false;
                    this.btnUpdate.Visible = true;
                }
                else
                {
                    this.btnUpdate.Visible = false;
                    this.btnAddnew.Visible = true;
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
 
        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            Boolean a = iniData.chkDupTrainingCompareGroup(txtID.Text);
            if (a == false)            
            { iniData.InsertTrainingCompareGroup(txtID.Text, txtName.Text,"1");}
           
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            Boolean b = iniData.chkDupTrainingCompareGroup(txtID.Text);
            if (b == false)
            { iniData.UpdateTrainingCompareGroup(lblID.Text, txtID.Text, txtName.Text, "1"); }
         
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }

    }
}